import sys
from random import *
from math import *

users = int(sys.argv[1])
movies = int(sys.argv[2])
p = float(sys.argv[3])

def f1(x,y):
	return sin((x * y) / users)

ratings = []

func = f1
max = min = func(0,0)


for u in range(0, users):
	ratings.append([])
	for i in range(0, movies):
		if random() < p:
			ratings[u].append( func(u,i) )
			if (ratings[u][i] > max): max = ratings[u][i]
			if (ratings[u][i] < min): min = ratings[u][i]
		else:
			ratings[u].append( None )

diff = max - min
	
for u in range(0, users):
	for i in range(0, movies):
		if ratings[u][i] != None:
			value = (float)(ratings[u][i] -  min) / diff
			value = (value * 4) + 1
			value = int(round(value))
			print str(u) + "," + str(i) + "," + str(value)